package juegoUI;

import java.awt.Color;

import juegoPlantaVsZombies.Juego;
import juegoPlantaVsZombies.Planta;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.ColumnLayout;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.layout.VerticalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.tables.Table;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;

public class JuegoWindow extends SimpleWindow<Juego> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public JuegoWindow(WindowOwner parent, Object model) {
		super(parent, new Juego());
		// TODO Auto-generated constructor stub
	}
	
	@Override
	protected void createMainTemplate(Panel mainPanel) {
		
		this.setTitle("Plantas vs Zombies");
		super.createMainTemplate(mainPanel);
		
		Panel principal = new Panel(mainPanel);
		principal.setLayout(new ColumnLayout(2));

		Panel jardinPanel = new Panel(principal);
		jardinPanel.setLayout(new VerticalLayout());
		
		Panel zombiesPanel = new Panel(principal);
		zombiesPanel.setLayout(new VerticalLayout());
		
		this.createButtons(jardinPanel);
		this.createTable(jardinPanel);
		this.createButtons(zombiesPanel);
		//this.createLeftPanel(zombiesPanel);
	}
	private void createTable(Panel jardinPanel) {
		
		Panel panel = new Panel(jardinPanel);
		panel.setLayout(new VerticalLayout());
		
		Table<Planta> table = new Table<Planta>(panel, Planta.class);
		table.setHeigth(200);
		table.setWidth(450);
	}

	/*
	private void createLeftPanel(Panel juegoPanel) {
		
		this.setTitle("Mi Jardin");
		this.setTaskDescription("Estas son las plantas dentro de mi jardin");

		super.createMainTemplate(juegoPanel);
		
		Table<Planta> table = new Table<Planta>(juegoPanel, Planta.class);
		table.setHeigth(200);
		table.setWidth(450);
		
	}
*/
	/*
	protected void createResultsGrid(Panel mainPanel) {
		Table<Planta> table = new Table<Planta>(mainPanel, Planta.class);
		table.setHeigth(200);
		table.setWidth(450);
	}
	*/
	private void createButtons(Panel mainPanel) {
		Panel panel = new Panel(mainPanel);
		panel.setLayout(new ColumnLayout(3));
		
		new Button(panel)
			.setCaption("Ir al Jardin Zen")
			.onClick(new MessageSend(this, "abrirJardinZen"));
		
		new Button(panel)
			.setCaption("Reiniciar");
			//.onClick(new MessageSend(this, "reiniciar"));
		
		new Button(panel)
			.setCaption("AlmanaqueZombie")
			.onClick(new MessageSend(this, "abrirAlmanaque"));
		
		new Label(panel).setText("Jardin").setForeground(Color.GREEN).setFontSize(15);
	}
	

	@Override
	protected void addActions(Panel arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void createFormPanel(Panel arg0) {
		// TODO Auto-generated method stub
		
	}
	
}
